namespace MvcTrialerNuGetDatabase.Migrations
{
    using System;
    using System.Data.Entity;
    using System.Data.Entity.Migrations;
    using System.Linq;
    using System.Configuration;
    using MvcTrialerNuGetDatabase.Models;

    internal sealed class Configuration : DbMigrationsConfiguration<MvcTrialerNuGetDatabase.Models.DataContext>
    {
        public Configuration()
        {
            AutomaticMigrationsEnabled = true;
        }

        protected override void Seed(MvcTrialerNuGetDatabase.Models.DataContext context)
        {
            //  This method will be called after migrating to the latest version.

            //  You can use the DbSet<T>.AddOrUpdate() helper extension method 
            //  to avoid creating duplicate seed data. E.g.
            //
            //    context.People.AddOrUpdate(
            //      p => p.FullName,
            //      new Person { FullName = "Andrew Peters" },
            //      new Person { FullName = "Brice Lambson" },
            //      new Person { FullName = "Rowan Miller" }
            //    );
            //

            if (ConfigurationManager.AppSettings["RunSeed"] == "true")
            {
                context.Users.AddOrUpdate(x => x.Email,
                    new User { Email = "bacerojc@yahoo.com", Password = "james1234", NickName = "James", TrialDate = DateTime.Now.AddSeconds(15) },
                    new User { Email = "john.doe@gmail.com", Password = "john1234", NickName = "John" },
                    new User { Email = "genibrown@hotmail.com", Password = "geni1234", NickName = "Geni", TrialDate = DateTime.Now.AddHours(2) }
                );
            }
        }
    }
}
